package day1204zy;

public class demo1 {
    public static void main(String[] args) throws Exception {
     stringToNumber("sdfgfd");
    }
    public static int stringToNumber(String s) throws Exception {
     if (s.equals(null)){
         throw new Exception("字符串不能为null");
     }else if (s.equals("")){
         throw new Exception("字符串不能为空");
     }
        try {
            return Integer.parseInt(s);
        } catch (NumberFormatException e) {
            throw new Exception("字符串转换失败");
        }
    }
}
